package com.sh.business.controller;

import java.util.List;

import cn.dev33.satoken.annotation.SaIgnore;
import com.sh.business.domain.vo.DailyInvestVo;
import com.sh.business.domain.vo.UserInvestStatisticsVo;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.sh.common.idempotent.annotation.RepeatSubmit;
import com.sh.common.log.annotation.Log;
import com.sh.common.web.core.BaseController;
import com.sh.common.mybatis.core.page.PageQuery;
import com.sh.common.core.domain.R;
import com.sh.common.core.validate.AddGroup;
import com.sh.common.core.validate.EditGroup;
import com.sh.common.log.enums.BusinessType;
import com.sh.common.excel.utils.ExcelUtil;
import com.sh.business.domain.vo.UserInvestVo;
import com.sh.business.domain.bo.UserInvestBo;
import com.sh.business.service.IUserInvestService;
import com.sh.common.mybatis.core.page.TableDataInfo;
import software.amazon.awssdk.core.document.VoidDocumentVisitor;

/**
 * 后台管理-用户投资记录
 *
 * @author ruoyi
 * @date 2024-10-08
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/userInvest")
public class UserInvestController extends BaseController {

    private final IUserInvestService userInvestService;

    /**
     * 补发2025-04-22，每日动态奖励消息
     */
    /*@SaCheckPermission("business:userInvest:resendMqMsg")
    @GetMapping("/resendMqMsg")
    public R<Void> resendMqMsg() {
        userInvestService.resendMqMsg();
        return R.ok();
    }*/

    /**
     * 手动创建定时任务
     */
    //@SaCheckPermission("business:userInvest:createAllJob")
    /*@SaIgnore
    @GetMapping("/createAllJob")
    public R<Void> createAllJob() {
        userInvestService.createAllJob();
        return R.ok();
    }*/

    /**
     * 查询用户投资记录列表
     */
    @SaCheckPermission("business:userInvest:list")
    @GetMapping("/list")
    public TableDataInfo<UserInvestVo> list(UserInvestBo bo, PageQuery pageQuery) {
        return userInvestService.queryInvestList(bo, pageQuery);
    }

    /**
     * 查询用户投资记录列表
     */
    @SaCheckPermission("business:userInvest:queryUserInvestStatistics")
    @GetMapping("/queryUserInvestStatistics")
    public R<UserInvestStatisticsVo> queryUserInvestStatistics(UserInvestBo bo) {
        return R.ok(userInvestService.queryUserInvestStatistics(bo));
    }

    /**
     * 查询日统计列表
     */
    @SaCheckPermission("business:userInvest:daily")
    @GetMapping("/daily")
    public TableDataInfo<DailyInvestVo> daily(PageQuery pageQuery) {
        return userInvestService.queryDailyInvest(pageQuery);
    }

    /**
     * 导出用户投资记录列表
     */
    @SaCheckPermission("business:userInvest:export")
    @Log(title = "用户投资记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(UserInvestBo bo, HttpServletResponse response) {
        List<UserInvestVo> list = userInvestService.queryList(bo);
        ExcelUtil.exportExcel(list, "用户投资记录", UserInvestVo.class, response);
    }

    /**
     * 获取用户投资记录详细信息
     *
     * @param id 主键
     */
    @SaCheckPermission("business:userInvest:query")
    @GetMapping("/{id}")
    public R<UserInvestVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(userInvestService.queryById(id));
    }

    /**
     * 新增用户投资记录
     */
    /*@SaCheckPermission("business:userInvest:add")
    @Log(title = "用户投资记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody UserInvestBo bo) {
        return toAjax(userInvestService.insertByBo(bo));
    }*/

    /**
     * 修改用户投资记录
     */
    /*@SaCheckPermission("business:userInvest:edit")
    @Log(title = "用户投资记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserInvestBo bo) {
        return toAjax(userInvestService.updateByBo(bo));
    }*/

    /**
     * 删除用户投资记录
     *
     * @param ids 主键串
     */
    /*@SaCheckPermission("business:userInvest:remove")
    @Log(title = "用户投资记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(userInvestService.deleteWithValidByIds(List.of(ids), true));
    }*/
}
